// pages/order/order.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		uid: "",
		data: '',
		pg: 1,
		cs: 0,
		http: getApp().globalData.map,
		pd:false,
		xs:0,
		data:[]
	},

	onShow: function() {
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				this.setData({
					uid: e.data,
					data:[]
				})
				this.tj()
			}
		})
	},
	tj() {
		let a=''
		if(this.data.cs==5){
			a='action=returnOrderList'
		}else{
			a='action=orderList&sta=' + this.data.cs
		}
		wx.request({
			url: getApp().globalData.http1 + a + '&uid=' + this.data.uid.uid + '&pg=' +
				this.data.pg,
			success: (e) => {
				console.log(e)
				let a=[]
				let nan=this.data.data
				e.data.data.forEach(function(item,index){
					nan.push(item)
				})
				e.data.data.forEach(function sta(item,index){
					if(item.status==1){
						a.push('待出库')
					}else if(item.status==2){
						a.push('已出库')
					}else if(item.status==4){
						a.push('已完成')
					}
				})
				if(e.data.data.length<15){
					this.setData({
						pd:true
					})
				}
				if(e.data.data.length==0){
					this.setData({
						xs:1
					})
				}else{
					this.setData({
						xs:0
					})
				}
				this.setData({
					data: nan,
					zt:a
				})
			}
		})
	},
	ovo() {
		if (this.data.pd == 'false') {
			let a = this.data.pg + 1
			this.setData({
				pg: a
			})
			this.tj()
		}
	},
	cut(e){
		console.log(e)
		this.setData({
			cs:e.currentTarget.dataset.id,
			pg:1,
			data:[]
		})
		this.tj()
	},
	dj(e){
		wx.navigateTo({
			url:'../goods/goods?id='+e.currentTarget.dataset.id+'&L=3'
		})
	},
	dj1(e){
		wx.navigateTo({
			url:'list/list?id='+e.currentTarget.dataset.id
		})
	},
	qrsh(e){
		wx.navigateTo({
			url:'../goods/goods?id='+e.currentTarget.dataset.id+'&L=3'
		})
	}
})
